package com.wiserp.rest.resource;

import java.util.List;

import org.restlet.resource.Get;
import org.restlet.resource.ResourceException;
import org.restlet.resource.ServerResource;

import com.wiserp.rest.helper.WhLocProdHelper;
import com.wiserp.rest.model.WhLocProd;

public class ProdStockResource extends ServerResource{
	private WhLocProdHelper whLocProdHelper;
	private String prodNo;
	private String batchNo;
    protected void doInit() throws ResourceException {
    	Object prodNoParam = getRequestAttributes().get("prodNo");
    	if(prodNoParam!=null)
    		prodNo = (String)prodNoParam;	
    	Object batchNoParam = getRequestAttributes().get("batchNo");
    	if(batchNoParam!=null)
    		batchNo = (String)batchNoParam;	
	}
    
    @Get
    public List<WhLocProd> getStock(){
    	if(batchNo == null)
    		return whLocProdHelper.findStockByProdNo(prodNo);
    	else
    		return whLocProdHelper.findStockByProdNoAndBatchNo(prodNo,batchNo);
    }

	public void setHelper(WhLocProdHelper whLocProdHelper) {
		this.whLocProdHelper = whLocProdHelper;
	}

}
